package com.zhitan.ems.app.iot.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * Treeselect树结构实体类
 * 
 * @author zhitan
 */
public class TreeGroupSelect implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private Long id;

    /** 节点名称 */
    private String label;

    /** 节点禁用 */
    private boolean disabled = false;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeGroupSelect> children;
    private GroupVO data;

    public TreeGroupSelect()
    {

    }
    public TreeGroupSelect(GroupVO group)
    {
    	if(group!=null) {
    		this.data=group;
            this.id = group.getGroupId();
            this.label = group.getGroupName();
            this.disabled = group.getStatus()!=1;
            if(group.getChildren()!=null&&group.getChildren().size()>0) {
            	this.children = group.getChildren().stream().map(TreeGroupSelect::new).collect(Collectors.toList());
            }else {
            	this.children=new ArrayList<TreeGroupSelect>();
            	this.disabled =false;
            }
    	}
    	
    }

    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public String getLabel()
    {
        return label;
    }

    public void setLabel(String label)
    {
        this.label = label;
    }

    public boolean isDisabled()
    {
        return disabled;
    }

    public void setDisabled(boolean disabled)
    {
        this.disabled = disabled;
    }

    public List<TreeGroupSelect> getChildren()
    {
        return children;
    }

    public void setChildren(List<TreeGroupSelect> children)
    {
        this.children = children;
    }

	public GroupVO getData() {
		return data;
	}

	public void setData(GroupVO data) {
		this.data = data;
	}
}
